import { ref } from "vue";
import { defineStore } from "pinia";
import { login } from "../api/api/login";

export const useLogin = defineStore(
    "login",
    () => {
        const data = ref({});
        const token = ref("");
        function loginreq(params) {
            login(params).then((res) => {
                console.log(res.data);
                data.value = res;
                token.value = res.data.data.token;
                localStorage.setItem("token", res.data.data.token);
            });
        }
        return { data, token, loginreq };
    },
    { persist: true }
);
